package com.yyfax.pay.third.model.to.fuiou.xml;

import java.io.StringWriter;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.io.xml.QNameMap;
import com.thoughtworks.xstream.io.xml.StaxDriver;
import com.thoughtworks.xstream.io.xml.StaxWriter;


@XStreamAlias("qrytransreq")
public class QueryPayoutReqData {
	
	public static final String PAY_OUT_CODE = "AP01";

	/**
	 * 版本号
	 */
	private String ver;
	
	/**
	 * 业务代码
	 */
	private String busicd;
	
	/**
	 * 原请求流水
	 */
	private String orderno;
	
	/**
	 * 开始日期
	 */
	private String startdt;
	
	/**
	 * 结束日期
	 */
	private String enddt;
	
	/**
	 * 交易状态
	 */
	private String transst;

	public String getVer() {
		return ver;
	}

	public void setVer(String ver) {
		this.ver = ver;
	}

	public String getBusicd() {
		return busicd;
	}

	public void setBusicd(String busicd) {
		this.busicd = busicd;
	}

	public String getOrderno() {
		return orderno;
	}

	public void setOrderno(String orderno) {
		this.orderno = orderno;
	}

	public String getStartdt() {
		return startdt;
	}

	public void setStartdt(String startdt) {
		this.startdt = startdt;
	}

	public String getEnddt() {
		return enddt;
	}

	public void setEnddt(String enddt) {
		this.enddt = enddt;
	}

	public String getTransst() {
		return transst;
	}

	public void setTransst(String transst) {
		this.transst = transst;
	}
	
	/**
	 * 该实体转换成XML字符串
	 * 
	 * @author heizq
	 * @date 2017-4-12 10:52:52
	 * @since v1.0.0
	 * @return 返回XML字符串
	 */
	public String toXml() {
		QNameMap qmap = new QNameMap();
		qmap.setDefaultPrefix("");
		StaxDriver staxDriver = new StaxDriver(qmap);
		XStream xstream = new XStream(staxDriver);
		xstream.autodetectAnnotations(true);
		xstream.ignoreUnknownElements();
		xstream.alias("qrytransreq", QueryPayoutReqData.class);
		try {
			StringWriter strWriter = new StringWriter();
			// don't do startDocument and do repair namespaces
			StaxWriter sw = new StaxWriter(staxDriver.getQnameMap(), staxDriver.getOutputFactory().createXMLStreamWriter(strWriter), false, true);
			xstream.marshal(this, sw);
			sw.close();
			return "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" + strWriter.toString();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	/**
	 * XML字符串转换成实体{@link PayReqData}
	 * 
	 * @author heizq
	 * @date 2017-4-12 10:53:28
	 * @since v1.0.0
	 * @param xml
	 * @return 返回{@link PayReqData}
	 */
	public static QueryPayoutReqData fromXml(String xml) {
		QNameMap qmap = new QNameMap();
		qmap.setDefaultPrefix("");
		StaxDriver staxDriver = new StaxDriver(qmap);
		XStream xstream = new XStream(staxDriver);
		xstream.autodetectAnnotations(true);
		xstream.ignoreUnknownElements();
		xstream.alias("qrytransreq", QueryPayoutReqData.class);
		return (QueryPayoutReqData) xstream.fromXML(xml);
	}
	
}
